import Layout from "@/layout/Index.vue"
import { buildRefreshRouter } from "@/hooks/refresh"
import { RouteRecordRaw } from "vue-router"

/**
 * 登录模块
 */
const authRoutes: RouteRecordRaw[] = [
    {
        path: "/login",
        name: "Login",
        component: () => import("@/views/auth/login/Index.vue"),
        meta: { needLogin: false }
    }
]

const commonRoutes: RouteRecordRaw[] = [
    {
        path: "/",
        name: "Home",
        redirect: "/dashboard"
    }
]

/**
 * 用户中心
 */
const ucenterRoutes: RouteRecordRaw[] = [
    {
        path: "/my",
        name: "ucenter",
        redirect: "/my/profile",
        component: Layout,
        children: [
            {
                path: "profile",
                name: "ucenter:profile",
                component: () => import("@/views/ucenter/profile/Index.vue"),
                meta: {
                    title: "用户中心"
                }
            },
            {
                path: "setting",
                name: "ucenter:setting",
                component: () => import("@/views/ucenter/setting/Index.vue"),
                meta: {
                    title: "用户设置"
                }
            }
        ]
    }
]

export const routes = [...authRoutes, ...commonRoutes, ...ucenterRoutes, buildRefreshRouter(Layout)]
